﻿package cn.antscript.autoView.viewer 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
	
	/**
	 * ...
	 * @author AntScript
     * @blog  http://www.antscript.cn
	 */
	public class Viewer extends BasicView
	{
		
		[Embed(source='../../../../../lib/269349.jpg')]
		private var Pic:Class;
		
		private var _window:Plane;
		private var _sight:DisplayObject3D;
		
		
		public function Viewer() 
		{
			init()
		}
		
		private function init():void
		{
			initDO3D();
		}
		
		
		
		private function initDO3D():void
		{
			var winMaterial:BitmapData = new BitmapData(1600, 1200, true, 0xff2579AC);
			for (var i:int = 0; i < 400; i++) 
			{
				for (var j:int = 0; j < 300; j++) 
				{
					winMaterial.setPixel32(i + (winMaterial.width-400)/2, j + (winMaterial.height-300)/2, 0x00ffffff);
				}
			}
			
			_window = new Plane(new BitmapMaterial(winMaterial), 1600, 1200,winMaterial.width/40,winMaterial.height/40);			
			scene.addChild(_window);
			
			_sight = new Plane(new BitmapMaterial((new Pic() as Bitmap).bitmapData), 1920, 1200, 10, 10);
			_sight.z = 1000;
			scene.addChild(_sight);			
			
		}
		
		
		public function setView(cX:Number, cY:Number, cZ:Number):void {
				_camera.x = cX;
				_camera.y = cY;
				_camera.z = cZ;
				super.singleRender();
		}
		
		
		
	}
	
}